package com.zretc.controller;

import com.zretc.service.MovieDetailsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Controller
@RequestMapping("/movieDetail")
public class MovieDetailController {
    private static  final Logger logger = LoggerFactory.getLogger(MovieDetailController.class);
    @Autowired
    private MovieDetailsService movieDetailsService;

    @RequestMapping("/getMovieMessage")
    @ResponseBody
    public Map getMovieMessage(String movieId){
        //调用业务层获取电影信息的方法
        Map<String,Object> movieMap = movieDetailsService.getMovieDetailsByMovieId(movieId);
        logger.info("========"+movieMap.toString());
        return movieMap;
    }

    @RequestMapping("/getCinemaMessage")
    @ResponseBody
    public List<Map<String,String>> getCinemaMessage(String movieId){
        //调用业务层获取影院名称的方法
        List<Map<String,String>> cinemaList = movieDetailsService.getCinemaByMovieId(movieId);
        logger.info("========"+cinemaList.toString());
        return cinemaList;
    }

    @RequestMapping("/getCinemaAndMovieMessage")
    @ResponseBody
    public List<Map<String,Object>> getCinemaAndMovieMessage(String movieId,
                                                             String date,
                                                             String cinemaName,
                                                             String typeName,
                                                             String hallName){
        Map<String,String> params = new HashMap<>();
        params.put("movieId",movieId);
        params.put("date",date);
        params.put("cinemaName",cinemaName);
        params.put("typeName",typeName);
        params.put("hallName",hallName);
        //调用业务层获取电影安排信息的方法
        List<Map<String,Object>> movieManageList = movieDetailsService.getMovieMessageForSelectSeat(params);
        logger.info("========"+movieManageList.toString());
        return movieManageList;
    }
}
